import request from "@/utils/request";
import { requestPath } from "@/utils/global.js";

export function freeCourseAPI(params) {
  //推荐位
  return request({
    url: `${requestPath.resource}/recommend/page`,
    method: "get",
    params
  });
}

export function seriesCourseAPI(params) {
  //系列课
  return request({
    url: `${requestPath.resource}/course-library/series/page`,
    method: "get",
    params
  });
}

export function listenCourseAPI(params) {
  //听解读
  return request({
    url: `${requestPath.resource}/course-library/listen/page`,
    method: "get",
    params
  });
}

export function classDetAPI(params) {
  //课程详情
  return request({
    url: `${requestPath.resource}/course-library/detail`,
    method: "get",
    params
  });
}

export function reviewAPI(params) {
  //课程-视频-音频评论列表
  return request({
    url: `${requestPath.resource}/comment/page`,
    method: "get",
    params
  });
}

export function agreeAPI(data) {
  //点赞
  return request({
    url: `${requestPath.resource}/comment/agree`,
    method: "post",
    data
  });
}

export function favAPI(data) {
  //收藏
  return request({
    url: `${requestPath.resource}/member-collection/batch/save`,
    method: "post",
    data
  });
}

export function cancelFavAPI(data) {
  //取消收藏
  return request({
    url: `${requestPath.resource}/member-collection/batch/delete`,
    method: "post",
    data
  });
}

export function myCourseAPI(params) {
  //我的课程列表
  return request({
    url: `${requestPath.order}/order/page/buy`,
    method: "get",
    params
  });
}

export function getLiveAPI(params) {
  //直播
  return request({
    url: `${requestPath.live}/live/page`,
    method: "get",
    params
  });
}

export function getDetPayAPI(params) {
  //中间页面（支付）直播
  return request({
    url: `${requestPath.live}/live/get/info?id=${params}`,
    method: "get"
  });
}

export function getDetAPI(params) {
  //获取回放
  return request({
    url: `${requestPath.live}/backplay/get/info?id=${params}`,
    method: "get"
  });
}

export function videoDetAPI(params) {
  //视频详情
  return request({
    url: `${requestPath.resource}/video-library/get/${params}`,
    method: "get"
  });
}
export function audioDetAPI(params) {
  //音频详情
  return request({
    url: `${requestPath.resource}/audio-library/get/${params}`,
    method: "get"
  });
}

export function videoTimeAPI(data) {
  //视频播放时长
  return request({
    url: `${requestPath.resource}/video-library/schedule/save`,
    method: "post",
    data
  });
}

export function getClassDetails(params) {
  //微课详情
  return request({
    url: `${requestPath.resource1}/smallclass/get/` + params,
    method: "get"
  });
}

export function favClassAPI(data) {
  //收藏
  return request({
    url: `${requestPath.member}/member-collection/batch/save`,
    method: "post",
    data
  });
}

export function cancelClassAPI(data) {
  //取消收藏
  return request({
    url: `${requestPath.member}/member-collection/batch/delete`,
    method: "post",
    data
  });
}

export function getVideoAPI(params) {
  //获m3u8地址
  return request({
    url: `file/file/get/video/m3u8?fileName=${params}`,
    method: "get"
  });
}

export function getAudioAPI(params) {
  //获音频地址
  return request({
    url: `file/file/getFilePath?fileName=${params}`,
    method: "get"
  });
}

export function getAudioList(params) {
  //获音频详情
  return request({
    url: `${requestPath.file}/file/getFilePath?fileName=${params}`,
    method: "get"
  });
}
